package com.example.xl.springboot01.users.controller;

import com.example.xl.springboot01.users.bean.JdDept;
import com.example.xl.springboot01.users.service.IJdDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class BaseController {
    @Autowired
    private IJdDeptService jdDeptServiceImpl;

    @GetMapping("/{page}")
    public String add(@PathVariable("page") String page) {
        return page;
    }

    @RequestMapping("/getJdDept")
    @ResponseBody
    @CrossOrigin
    public List<JdDept> getJdDept(HttpServletRequest req) {
        Integer pid = req.getParameter("pid") == null ? 1 : Integer.parseInt(req.getParameter("pid").toString());
        List<JdDept> category =  jdDeptServiceImpl.getJdDept(pid);
        return category;
    }


}
